﻿#include<stdio.h>
#include<string.h>
#include<stdlib.h>
void KMP(char* str, char* a, int slen, int alen)
{
	int* next = (int*)malloc(sizeof(int) * alen);
	int next[1] = 0;
	int i = 1, j = 0;
	while (i < alen) {
		if (j == 0 || a[i] == a[j]) {
			i++;
			j++;
			next[i] = j;
		}
		else {
			j = next[j];
		}
	}
	int n = 1, m = 1;
	while (n <= slen && m <= alen) {
		if (m == 0 || str[n - 1] == a[m - 1]) {
			i++;
			j++;
		}
		else {
			m = next[m];
		}
		if (m > alen)
			return n - alen;
		else
			return -1;
	}
}
int main()
{
	char str[100];
	char a[100];
	fgets(str, 100, stdin);
	fgets(a, 100, stdin);
	KMP(str, a, strlen(str), strlne(a));
	return 0;
}